<script setup>
import mainAside from './component/main-aside.vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import cache from '@/util/cache.js'
import { ref } from 'vue'
const store = useStore()
const router = useRouter()
const handOutClick = () => {
  cache.deleteCache('jxcms-token')
  cache.deleteCache('jxcms-user')
  router.push('/login')
}
const isCollapse = ref(false)
const handCollapseClick = () => {
  isCollapse.value = !isCollapse.value
}
</script>

<template>
  <div class="goods">
    <div class="common-layout">
      <el-container>
        <el-aside :width="isCollapse ? '60px' : '216px'">
          <mainAside :isCollapse="isCollapse"></mainAside>
        </el-aside>
        <el-container>
          <el-header>
            <div class="header">
              <el-icon size="30" @click="handCollapseClick"><Fold /></el-icon>
              <div class="user">
                <img
                  src="https://s1.boluo.link/imgs/2022/12/02/3ac0a824e1fd00cb.jpg"
                />
                <el-dropdown>
                  <span class="el-dropdown-link">
                    <span>{{ store.state.user.userInfo.uName }}</span>
                    <el-icon class="el-icon--right">
                      <arrow-down />
                    </el-icon>
                  </span>
                  <template #dropdown>
                    <el-dropdown-menu>
                      <el-dropdown-item>修改用户信息</el-dropdown-item>
                      <el-dropdown-item divided @click="handOutClick"
                        >退出登录</el-dropdown-item
                      >
                    </el-dropdown-menu>
                  </template>
                </el-dropdown>
              </div>
            </div>
          </el-header>
          <el-main>
            <div class="main">1</div>
          </el-main>
        </el-container>
      </el-container>
    </div>
  </div>
</template>

<style lang="less" scoped>
.el-aside {
  transition: width 0.15s;
  -webkit-transition: width 0.15s;
  -moz-transition: width 0.15s;
  -webkit-transition: width 0.15s;
  -o-transition: width 0.15s;
}
:deep(.el-aside) {
  margin-right: 6px;
  box-shadow: 6px 0 15px rgba(119, 119, 119, 0.1);
}
.el-header {
  height: 52px;
  background: #fff;
}
.el-main {
  background: #f3f5f8;
}
.el-icon {
  cursor: pointer;
}
.header {
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .user {
    display: flex;
    align-items: center;
    margin-right: 30px;
    img {
      margin-right: 10px;
      width: 34px;
      height: 34px;
      border-radius: 10px;
    }
  }
}
</style>
